
$(document).ready(function () {
  let obj=new Object();
  obj.m="list";
  $.ajax({
       async:true,
       type:"GET",
       url:basePath2+"/api/category",
       dataType:"json",
       data:obj,
        success:function (result) {
            console.log(result);
            initCategory(result);
        },
      error:function (e) {
          console.log(e.status);
          console.log(e.responseText);
      }
   });
});
//初始化商品类型列表
function initCategory(result) {
    $(".searchContent").html("");//清空值
    let header_option=$("<option></option>");
    header_option.text("所有商品");
    //加入到$(".searchContent")
    header_option.attr("value",-1);
    $(".searchContent").append(header_option);
    //遍历json数组‘
    $.each(result,function (index,element) {
        console.log(element);
        let option=$("<option></option>").text(element.cateName);
        option.attr("value",element.id);
        $(".searchContent").append(option);
    })

}